home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / bbs / mhis020.zip / CALLERS.MH < prev    next >
Text File  |  1996-09-10  |  3KB  |  103 lines

  1. #ifndef __CALLERS_MH
  2. #define __CALLERS_MH
  3.  
  4. #ifndef __GENERAL_MH
  5. #include "general.mh"
  6. #endif
  7.  
  8. #ifndef __CALLSETT_MH
  9. #include "callsett.mh"
  10. #endif
  11.  
  12. #ifndef __DATAFILE_MH
  13. #include "datafile.mh"
  14. #endif
  15.  
  16. struct _callcriteria {
  17.   string:               name;
  18.   string:               city;
  19.   unsigned int:         min_priv;
  20.   unsigned int:         max_priv;
  21.   string:               good_keys;
  22.   string:               bad_keys;
  23.   unsigned int:         min_calls;
  24.   int:                  task;
  25.   int:                  good_flags;
  26.   int:                  bad_flags;
  27.   };
  28.  
  29. struct _callers {
  30.   long:                 index;
  31.   bool:                 forward_search;
  32.   struct _callcriteria: criteria;
  33.   };
  34.  
  35. struct _callers: callers;
  36.  
  37. void clear_criteria (Ref struct _callcriteria: c) {
  38.   c.name        := "*";
  39.   c.city        := "*";
  40.   c.min_priv    := 0x0000;
  41.   c.max_priv    := 0xffff;
  42.   c.good_keys   := "";
  43.   c.bad_keys    := "";
  44.   c.min_calls   := 0;
  45.   c.task        := -1;
  46.   c.good_flags  := 0;
  47.   c.bad_flags   := 0;
  48.   }
  49.  
  50. void read_criteria (int: fd, struct _callcriteria: c) {
  51.   c.name        := datafile_str  (fd);
  52.   c.city        := datafile_str  (fd);
  53.   c.min_priv    := datafile_long (fd);
  54.   c.max_priv    := datafile_long (fd);
  55.   c.good_keys   := datafile_str  (fd);
  56.   c.bad_keys    := datafile_str  (fd);
  57.   c.min_calls   := datafile_long (fd);
  58.   c.task        := datafile_long (fd);
  59.   c.good_flags  := datafile_long (fd);
  60.   c.bad_flags   := datafile_long (fd);
  61.   }
  62.  
  63. void write_criteria (int: fd, struct _callcriteria: c) {
  64.   writeln (fd, c.name);
  65.   writeln (fd, c.city);
  66.   writeln (fd, itostr (c.min_priv));
  67.   writeln (fd, itostr (c.max_priv));
  68.   writeln (fd, c.good_keys);
  69.   writeln (fd, c.bad_keys);
  70.   writeln (fd, itostr (c.min_calls));
  71.   writeln (fd, itostr (c.task));
  72.   writeln (fd, itostr (c.good_flags));
  73.   writeln (fd, itostr (c.bad_flags));
  74.   }
  75.  
  76. void read_callers () {
  77.   int: fd;
  78.   string: line;
  79.  
  80.   if (fileexists (CALLERS_TEMP_FILE) = False) {         // If the file doesn't exist,
  81.     callers.index := 0;
  82.     clear_criteria (callers.criteria);
  83.     callers.forward_search := True;
  84.     return;
  85.     };
  86.   fd := open (CALLERS_TEMP_FILE, IOPEN_READ);
  87.   callers.index := datafile_long (fd);
  88.   callers.forward_search := datafile_long (fd);
  89.   read_criteria (fd, callers.criteria);
  90.   close (fd);
  91.   }
  92.  
  93. void write_callers () {
  94.   int: fd;
  95.   fd := open (CALLERS_TEMP_FILE, IOPEN_WRITE | IOPEN_CREATE);
  96.   writeln (fd, ltostr (callers.index));
  97.   writeln (fd, itostr (callers.forward_search));
  98.   write_criteria (fd, callers.criteria);
  99.   close (fd);
  100.   }
  101.  
  102. #endif
  103.